<!-- 人气推荐 -->
<script setup>
import { reactive, ref } from "vue";
import { NSpace, NSkeleton } from "naive-ui";
import { useLazyData } from "@/utils";
import Pannel from "@/components/home/home-panel.vue";
import { findHots } from "@/api/home";

const homeHot = ref(null);
let list = useLazyData(homeHot, findHots);
</script>

<template>
  <div class="home-hot" ref="homeHot">
    <Transition>
      <div class="flex-around" v-if="list.length <= 0" style="margin: 30px 0px">
        <n-space vertical v-for="i in 4" :key="i">
          <n-skeleton height="306px" width="306px" />
          <n-skeleton height="30px" width="306px" />
          <n-skeleton height="30px" width="306px" />
        </n-space>
      </div>
      <Pannel title="人气推荐" subTitle="人气爆款 不容错误" v-else>
        <!-- 面板内容 -->
        <ul class="goods-list">
          <li v-for="item in list" :key="item.id">
            <RouterLink to="/">
              <img v-lazy="item.picture" alt />
              <p class="name ellipse">{{ item.title }}</p>
              <p>{{ item.alt }}</p>
            </RouterLink>
          </li>
        </ul>
      </Pannel>
    </Transition>
  </div>
</template>

<style lang='less' scoped>
.goods-list {
  display: flex;
  justify-content: space-between;
  li {
    width: 306px;
    height: 390px;
    text-align: center;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    .name,
    .desc {
      font-size: 14px;
      font-family: "Microsoft Yahei", "微软雅黑", verdana;
      padding: 0px 30px 0 30px;
    }
    .name {
      padding-top: 15px;
      font-weight: bold;
    }
    .desc {
      color: #999;
      padding-top: 2px;
      font-size: 18px;
    }
    &:hover {
      background-color: #dffff8;
    }
  }
}
</style>